package com.qingke.ssh.bean;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.apache.struts2.json.JSONResult;
import org.springframework.stereotype.Component;

import com.google.gson.JsonObject;

@Component
@Entity
@Table(name = "employee")
public class Employee {
	@Id
	@Column(name = "id")
	private int id;
	@Column(name = "name")
	private String name;
	@Column(name = "phone")
	private String phone;
	@Column(name = "mail")
	private String mail;
	@Column(name = "hiredate")
	private Date hiredate;
	@OneToOne(mappedBy = "employee")

	private EmployeeLogin employeeLogin;
	@ManyToOne
	@JoinColumn(name = "employee_type_id")
	private EmployeeType employeeType;

	public Employee(String name, String phone, String mail, Date hiredate) {
		super();
		this.name = name;
		this.phone = phone;
		this.mail = mail;
		this.hiredate = hiredate;
	}

	public Employee() {
		super();
	}

	public int getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getPhone() {
		return phone;
	}

	public String getMail() {
		return mail;
	}

	public Date getHiredate() {
		return hiredate;
	}

	public EmployeeLogin getEmployeeLogin() {
		return employeeLogin;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public void setHiredate(Date hiredate) {
		this.hiredate = hiredate;
	}

	public void setEmployeeLogin(EmployeeLogin employeeLogin) {
		this.employeeLogin = employeeLogin;
	}

	public EmployeeType getEmployeeType() {
		return employeeType;
	}

	public void setEmployeeType(EmployeeType employeeType) {
		this.employeeType = employeeType;
	}

	@Override
	public String toString() {
		JsonObject json = JSONObject.fromObject(this);
		return json.toString();
	}

}
